from pages.base_page import BasePage
from selenium.webdriver.common.by import By


class ProductHomePage(BasePage):
    url = '/crm/index.php?m=product'
    #定位器
    add_product_btn = (By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(2) > div.pull-right > a')
    field_product_locator = (By.ID,'field')
    search_input_locator = (By.ID,'search')
    #搜索按钮
    dosearch_locator = (By.ID,'dosearch')
    #页码
    next_page_locator = (By.CSS_SELECTOR,'#td_colspan > div.pagination > div.span4 > div > ul > li:nth-child(4) > a')
    up_page_locator = (By.CSS_SELECTOR,'#td_colspan > div.pagination > div.span4 > div > ul > li:nth-child(2) > a')
    first_page_locator = (By.CSS_SELECTOR,'#td_colspan > div.pagination > div.span4 > div > ul > li:nth-child(1) > a')

    def click_add_product_btn(self):
        self.driver.find_element(*self.add_product_btn).click()
    def select_field_product(self):
        return self.driver.find_element(*self.field_product_locator)
    def input_search(self,search_text):
        self.driver.find_element(*self.search_input_locator).send_keys(search_text)
    def click_dosearch(self):
        self.driver.find_element(*self.dosearch_locator).click()

    def next_page(self):
        self.driver.find_element(*self.next_page_locator).click()
    def up_page(self):
        self.driver.find_element(*self.up_page_locator).click()
    def first_page(self):
        self.driver.find_element(*self.first_page_locator).click()













